package com.frinder.demo.delimiter;

import com.frinder.base.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;

/**
 * @ClassName DelimiterUtils
 * @Description 工具类
 * @Author frinder
 * @Date 2019/4/16 14:29
 * @Verion 1.0
 */
public class DelimiterUtils {

    public static final String DELIMITER = "#";

    /**
     * @Author frinder
     * @Description 分割符
     * @Date 2019/4/16 14:16
     * @Param [delimiterStr]
     * @Return io.netty.buffer.ByteBuf
     */
    public static ByteBuf delimiter() {
        return ByteBufUtils.buf(DELIMITER);
    }

    /**
     * @Author frinder
     * @Description 编码器
     * @Date 2019/4/16 14:30
     * @Param [delimiterStr]
     * @Return io.netty.handler.codec.DelimiterBasedFrameDecoder
     */
    public static DelimiterBasedFrameDecoder decoder() {
        return new DelimiterBasedFrameDecoder(
                1024,
                true,
                true,
                delimiter()
        );
    }

}
